<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class ImageUpload extends CI_Controller{

    function __construct() {
        parent::__construct();
    }
    
    function index(){
    	$this->load->library('uploadhandler');
        header('Pragma: no-cache');
		header('Cache-Control: no-store, no-cache, must-revalidate');
		header('Content-Disposition: inline; filename="files.json"');
		header('X-Content-Type-Options: nosniff');
		header('Access-Control-Allow-Origin: *');
		header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
		header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');
		
		switch ($_SERVER['REQUEST_METHOD']) {
		    case 'OPTIONS':
		        break;
		    case 'HEAD':
		    case 'GET':
		        $this->uploadhandler->get();
		        break;
		    case 'POST':
		        if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
		            $this->uploadhandler->delete();
		        } else {
		            $this->uploadhandler->post();
		        }
		        break;
		    case 'DELETE':
		        $this->uploadhandler->delete();
		        break;
		    default:
		        header('HTTP/1.1 405 Method Not Allowed');
		    }
	}
}
?>